"use strict"

const Controller = require('egg').Controller

class UploadController extends Controller {
    // 上传
    async index() {
        const { ctx } = this
        const mkdir = ctx.request.body.mkdir
        const files = ctx.request.files;        // 请求文件
        ctx.body = await ctx.helper._upload(files, mkdir)
    }
    // 查询图片
    async imgs_list() {
        const { ctx } = this
        ctx.body = await ctx.service.admin.upload.imgs_list(ctx.request.body)
    }
    // 删除图片
    async del_imgs() {
        const { ctx } = this
        ctx.body = await ctx.service.admin.upload.del_imgs(ctx.request.body)
    }
    // 查询目录
    async list_mkdir() {
        const { ctx } = this
        ctx.body = await ctx.service.admin.upload.list_mkdir()
    }
    // 新增目录
    async add_mkdir() {
        const { ctx } = this
        ctx.body = await ctx.service.admin.upload.add_mkdir(ctx.request.body)
    }
    // 删除目录
    async del_mkdir() {
        const { ctx } = this
        ctx.body = await ctx.service.admin.upload.del_mkdir(ctx.request.body)
    }
    // 移动目录
    async move_mkdir(){
        const { ctx } = this
        ctx.body = await ctx.service.admin.upload.move_mkdir(ctx.request.body)
    }
}

module.exports = UploadController